<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
<!--        <el-button v-if="isAuth('purchase:enquire:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>-->
<!--        <el-button v-if="isAuth('purchase:enquire:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>-->
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"

      v-loading="dataListLoading"
      style="width: 100%;">
<!--      <el-table-column-->
<!--        type="selection"-->
<!--        header-align="center"-->
<!--        align="center"-->
<!--        width="50">-->
<!--      </el-table-column>-->

      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-form-item label="序号:">
              <span>{{ props.row.id }}</span>
            </el-form-item>
  <br>
            <el-form-item label="询价书编号:">
              <span>{{ props.row.enquireNum }}</span>
            </el-form-item>
  <br>
            <el-form-item width="200" label="询价书名称:">
              <span>{{ props.row.enquireName }}</span>
            </el-form-item>
  <br>
            <el-form-item label="单位:">
              <span>{{ props.row.company }}</span>
            </el-form-item>
  <br>
            <el-form-item label="联系人:">
              <span>{{ props.row.linkman }}</span>
            </el-form-item>
  <br>
            <el-form-item label="联系地址:">
              <span>{{ props.row.address }}</span>
            </el-form-item>
  <br>
            <el-form-item label="联系电话:">
              <span>{{ props.row.phone }}</span>
            </el-form-item>
  <br>
            <el-form-item label="联系传真:">
              <span>{{ props.row.fax }}</span>
            </el-form-item>
  <br>
            <el-form-item label="邮编:">
              <span>{{ props.row.zip }}</span>
            </el-form-item>
  <br>
            <el-form-item label="电子邮箱:">
              <span>{{ props.row.email }}</span>
            </el-form-item>
  <br>
            <el-form-item label="报价截止时间:">
              <span>{{ props.row.endDate }}</span>
            </el-form-item>
  <br>
            <el-form-item label="备注:">
              <span>{{ props.row.remark }}</span>
            </el-form-item>
  <br>
          </el-form>
        </template>
      </el-table-column>

<!--      <el-table-column-->
<!--        prop="id"-->
<!--        header-align="center"-->
<!--        align="center"-->
<!--        label="序号">-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        prop="enquireNum"-->
<!--        header-align="center"-->
<!--        align="center"-->
<!--        label="询价书编号">-->
<!--      </el-table-column>-->
      <el-table-column
        prop="enquireName"
        header-align="center"
        align="center"
        label="询价书名称">
      </el-table-column>
      <el-table-column
        prop="company"
        header-align="center"
        align="center"
        label="单位">
      </el-table-column>
      <el-table-column
        prop="linkman"
        header-align="center"
        align="center"
        label="联系人">
      </el-table-column>
      <el-table-column
        prop="address"
        header-align="center"
        align="center"
        label="联系地址">
      </el-table-column>
      <el-table-column
        prop="phone"
        header-align="center"
        align="center"
        label="联系电话">
      </el-table-column>
<!--      <el-table-column-->
<!--        prop="fax"-->
<!--        header-align="center"-->
<!--        align="center"-->
<!--        label="联系传真">-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        prop="zip"-->
<!--        header-align="center"-->
<!--        align="center"-->
<!--        label="邮编">-->
<!--      </el-table-column>-->
      <el-table-column
        prop="email"
        header-align="center"
        align="center"
        label="电子邮箱">
      </el-table-column>
      <el-table-column
        prop="endDate"
        header-align="center"
        align="center"
        label="报价截止时间">
      </el-table-column>
      <el-table-column
        prop="remark"
        header-align="center"
        align="center"
        label="备注">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="MakeContractApply(scope.row.id)">编制合同</el-button>

        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>

  </div>
</template>

<script>
  import AddOrUpdate from '../contract/contract-add-or-update.vue'
  export default {
    data () {
      return {
        dataForm: {
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    components: {
      AddOrUpdate
    },
    mounted () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList() {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/purchase/enquire/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'key': this.dataForm.key,
            'reveal':'true'
          })
        }).then((data) => {
          if (data && data.code === 200) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 编制合同申请

      MakeContractApply(id){
        this.$router.push({name: 'make-contract-apply', query: {id: id}})
      }
    }

  }
</script>
